﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;

using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.BehaviorTree;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.Logic.POI;
using Styx.WoWInternals.WoWObjects;
using TreeSharp;
using Action = TreeSharp.Action;
using Sequence = TreeSharp.Sequence;
using Styx.WoWInternals;

namespace Healz.Druid
{
    public static class PlayerManager
    {
        
        public static WoWPlayer PlayerToHeal(int PlayerStackCount)
        {
            try
            {
                return (from Unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false, false)
                        orderby Unit.HealthPercent ascending
                        where !Unit.Dead
                        where Unit.Distance < 40
                        where Unit.HealthPercent < 95
                        where Unit.IsFriendly
                        where !Unit.IsPet
                        where Unit.InLineOfSight
                        select Unit).ElementAt(PlayerStackCount);
            }
            catch (Exception)
            {
                return null;
            }
        }

        public static int RejuvCount()
        {
            return (int)(from Unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false, true)
                         where !Unit.Dead
                         where Unit.IsFriendly
                         where !Unit.IsPet
                         where Unit.HasAura("Rejuvenation")
                         select Unit).Count();
        }

    }
}
